let app = getApp()
var stylecss = require('../../utils/stylecss.js');
Component({
    properties: { 
      scrollTop: {
        type: Number,
        observer: function(newVal, oldVal) {
          this.updatscroll()
        }
      },
        vueId:String,
        item: {
          type: Object,
          observer: function(newVal, oldVal) {
            this.updateRate()
          }
        }
      },
      data:{
      
      },  
    lifetimes: {
        attached: function () {
          
       }
      },
    methods: {
      updatscroll:function(){
        var nowtop=this.data.scrollTop-this.data.top
        var oldanima=this.data.oldanima
        if(nowtop<=0){
         this.setData({
           anima:oldanima
         })
        }else{
          this.setData({
              anima:''
          })
        }
     },
      updateRate:function(){
        var css='';
        var that=this
        const query = wx.createSelectorQuery().in(this)
        setTimeout(() => { 
           query.select('#'+this.data.vueId).boundingClientRect(res=>{
                 if(res==null){
                   that.setData({
                       top:0
                   })
                 }else{
                  that.setData({
                    top:res.top
                  })
                 }
              }).exec();
         }, 0);
        var css=stylecss.css(this.data.vueId);
        var anima=stylecss.animated(this.data.vueId);
        var id2=this.data.vueId+' .wqdDtext';
        var css2=stylecss.css(id2);
        this.setData({
            oldanima:anima,
            anima:anima,
            css:css,
            css2:css2
        })
      },
      jumpurl:function(e){
        stylecss.jumpurl(this.data.item.link);
      }
    }
});
